<template>
  <el-container class="home-container">
    <el-header>
      <h1>智慧医疗医生端</h1>
      <el-button type="danger" @click="logout">退出</el-button>
    </el-header>
    <el-container>
          <!-- :collapse='isCollapse'
          :collapse-transition='false' -->
      <el-aside width='200px'>
        <div class="top">
            <span><i class="el-icon-s-tools"></i></span>
            <span><i class="el-icon-top-right"></i></span>
        </div>
        <img class="avatar" src="../assets/hh.jpg" alt="">
        <div class="user">
          管理员
        </div>
        <el-menu
          background-color="#233046"
          text-color="#fff"
          active-text-color="#ffd04b"
          :unique-opened='true'
          :default-active='activePath'
          router>
          <el-menu-item :index="'/'+item.path"
          @click="saveNavState('/'+item.path)"
          v-for="item in menuList" :key="item.id">
              <template slot="title">
                <i :class="iconsObj[item.id]"></i>
                <span>{{item.title}}</span>
              </template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data(){
    return {
      menuList:[
        {
          id:"1",
          title:'接诊台',
          path:'admission'
        },
        {
          id:"2",
          title:'诊断管理',
          path:'diagnosis'
        },
        {
          id:"3",
          title:'直播管理',
          path:'live'
        },
        {
          id:"4",
          title:'我的钱包',
          path:'wallet'
        }
      ],
      iconsObj: {
        "1": 'iconfont icon-user',
        "2": 'iconfont icon-tijikongjian',
        "3": 'iconfont icon-shangpin',
        "4": 'iconfont icon-danju'
      },
      activePath:''
    }
  },
  created(){
    this.activePath = sessionStorage.getItem('activePath')
  },
  methods:{
    logout(){
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    saveNavState (activePath) {
      sessionStorage.setItem('activePath', activePath)
      this.activePath = activePath
    }
  }
}
</script>

<style lang='scss' scoped>
.home-container{
  height: 100%;
  width: 100%;
}
.el-header{
  background: #4381E6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 50px;
  h1{
    color: #fff;
  }
}
.top {
  height: 40px;
  display: flex;
  justify-content: space-between;
  color: #fff;
  line-height: 40px;
  padding: 0 15px;
  i{
    font-size: 18px;
  }
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-left: 60px;
}

.user {
  width: 100%;
  height: 30px;
  font-size: 17px;
  color: #fff;
  font-weight: bold;
  text-align: center;
  margin-top: 15px;
}
.el-aside{
  background: #233046;
}
.el-main{
  background: #eee;
}

.el-menu-item {
  text-align: center;
  i{
    font-size: 20px;
  }
  span{
    margin-left: 15px;
  }
}
</style>